// userPageA/pages/topupSuccess/topupSuccess.js
const app = getApp()
const WXAPI = require("../../../api/api")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    nvabarData: {
      showCapsule: 1, // 是否显示左上角图标   1表示显示    0表示不显示
      title: ' ', // 导航栏 中间的标题
      textColor: '#333', // 标题颜色
      bgColor: '#FAFAFA', // 导航栏背景颜色
      backUrl: '/pages/userMarket/userMarket'
    },
    orderId: '',
    pathType: '',
    orderData: {},
    imgHttp: app.globalData.imgHttp,//图片前缀
    isMaidian: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // var orderId = '1383360111147954178'
    // var pathType ='noToken'
    var orderId = options.orderId
    var pathType = options.pathType
    var isMaidian = ''
    if(pathType == 'noToken'){
      isMaidian = true
    }else{
      isMaidian = false
    }
    this.setData({
      orderId: orderId,
      isMaidian: isMaidian,
      pathType: pathType,
    })
    this.getorderStatus()
    this.dialog = this.selectComponent("#auth_dialog"); 
    
  },
  getorderStatus(){
    const that = this
    var data = {
      orderId: this.data.orderId,
    }
    WXAPI.getRechargePayResult(data, (res) =>{
      const data = res.result
      console.log("获取支付结果",res)
      if(res.code == 200){
        this.setData({
          orderData: res.result,
        })
      }
    })
  },
  handleAsster(){
    wx.switchTab({
      // url: '/pages/assets/assets',
      url:'/pages/userMarket/userMarket'
    })
  },
  handleToken(){
    var token = wx.getStorageSync('token')
    this.dialog.showPhone()
  },
  refreshintegral(){
    this.setData({
      isMaidian: false
    })
    this.getVou()
  },
  getVou(){
    var data = {
      orderId: this.data.orderId
    }
    WXAPI.receiveAnonymousOrder(data,(res) => {
      if(res.codd == 200){
        wx.switchTab({
          // url: '/pages/assets/assets',
          url:'/pages/userMarket/userMarket'
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})